//
//  NSDate+Extension.swift
//  01sinablog
//
//  Created by ZhangZiang on 15/12/29.
//  Copyright © 2015年 ZhangZiang. All rights reserved.
//

import Foundation

extension NSDate {
    //将字符串转换成日期对象
    func sinaDate(str : String) -> NSDate? {
        let dateForm = NSDateFormatter()
        
        dateForm.dateFormat = "EEE MMM dd HH:mm:ss zzz yyyy"
        
        dateForm.locale = NSLocale(localeIdentifier: "en")
        
        let date = dateForm.dateFromString(str)
        
        return date
    }
    
    //将日期对象转换成字符串
    func fullStr() -> String? {
        let dateForm = NSDateFormatter()
        
        dateForm.dateFormat = "yyyy-MM-dd HH:mm:ss"
        
        let str = dateForm.stringFromDate(self)
        
        return str
    }
}